//
// IMeshGeom.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.IStreamable;

public class IMeshGeom extends IStreamable {
  private long swigCPtr;

  public IMeshGeom(long cPtr, boolean cMemoryOwn) {
    super(nel3dJNI.IMeshGeom_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(IMeshGeom obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_IMeshGeom(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public void initInstance(CMeshBaseInstance mbi) {
    nel3dJNI.IMeshGeom_initInstance(swigCPtr, this, CMeshBaseInstance.getCPtr(mbi), mbi);
  }

  public boolean clip(SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t arg0, SWIGTYPE_p_NLMISC__CMatrix arg1) {
    return nel3dJNI.IMeshGeom_clip(swigCPtr, this, SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t.getCPtr(arg0), SWIGTYPE_p_NLMISC__CMatrix.getCPtr(arg1));
  }

  public void render(IDriver drv, CTransformShape trans, float polygonCount, long rdrFlags, float globalAlpha) {
    nel3dJNI.IMeshGeom_render(swigCPtr, this, IDriver.getCPtr(drv), drv, CTransformShape.getCPtr(trans), trans, polygonCount, rdrFlags, globalAlpha);
  }

  public void renderSkin(CTransformShape trans, float alphaMRM) {
    nel3dJNI.IMeshGeom_renderSkin(swigCPtr, this, CTransformShape.getCPtr(trans), trans, alphaMRM);
  }

  public boolean hasMeshVertexProgram() {
    return nel3dJNI.IMeshGeom_hasMeshVertexProgram(swigCPtr, this);
  }

  public void profileSceneRender(CRenderTrav rdrTrav, CTransformShape trans, float polygonCount, long rdrFlags) {
    nel3dJNI.IMeshGeom_profileSceneRender(swigCPtr, this, CRenderTrav.getCPtr(rdrTrav), rdrTrav, CTransformShape.getCPtr(trans), trans, polygonCount, rdrFlags);
  }

  public float getNumTriangles(float distance) {
    return nel3dJNI.IMeshGeom_getNumTriangles(swigCPtr, this, distance);
  }

  public SWIGTYPE_p_NLMISC__CAABBoxExt getBoundingBox() {
    return new SWIGTYPE_p_NLMISC__CAABBoxExt(nel3dJNI.IMeshGeom_getBoundingBox(swigCPtr, this), false);
  }

  public boolean supportMeshBlockRendering() {
    return nel3dJNI.IMeshGeom_supportMeshBlockRendering(swigCPtr, this);
  }

  public boolean sortPerMaterial() {
    return nel3dJNI.IMeshGeom_sortPerMaterial(swigCPtr, this);
  }

  public long getNumRdrPassesForMesh() {
    return nel3dJNI.IMeshGeom_getNumRdrPassesForMesh(swigCPtr, this);
  }

  public long getNumRdrPassesForInstance(CMeshBaseInstance inst) {
    return nel3dJNI.IMeshGeom_getNumRdrPassesForInstance(swigCPtr, this, CMeshBaseInstance.getCPtr(inst), inst);
  }

  public void beginMesh(CMeshGeomRenderContext rdrCtx) {
    nel3dJNI.IMeshGeom_beginMesh(swigCPtr, this, CMeshGeomRenderContext.getCPtr(rdrCtx), rdrCtx);
  }

  public void activeInstance(CMeshGeomRenderContext rdrCtx, CMeshBaseInstance inst, float polygonCount, SWIGTYPE_p_void vbDst) {
    nel3dJNI.IMeshGeom_activeInstance(swigCPtr, this, CMeshGeomRenderContext.getCPtr(rdrCtx), rdrCtx, CMeshBaseInstance.getCPtr(inst), inst, polygonCount, SWIGTYPE_p_void.getCPtr(vbDst));
  }

  public void renderPass(CMeshGeomRenderContext rdrCtx, CMeshBaseInstance inst, float polygonCount, long rdrPass) {
    nel3dJNI.IMeshGeom_renderPass(swigCPtr, this, CMeshGeomRenderContext.getCPtr(rdrCtx), rdrCtx, CMeshBaseInstance.getCPtr(inst), inst, polygonCount, rdrPass);
  }

  public void endMesh(CMeshGeomRenderContext rdrCtx) {
    nel3dJNI.IMeshGeom_endMesh(swigCPtr, this, CMeshGeomRenderContext.getCPtr(rdrCtx), rdrCtx);
  }

  public boolean getVBHeapInfo(SWIGTYPE_p_unsigned_int arg0, SWIGTYPE_p_unsigned_int arg1) {
    return nel3dJNI.IMeshGeom_getVBHeapInfo(swigCPtr, this, SWIGTYPE_p_unsigned_int.getCPtr(arg0), SWIGTYPE_p_unsigned_int.getCPtr(arg1));
  }

  public void computeMeshVBHeap(SWIGTYPE_p_void arg0, long arg1) {
    nel3dJNI.IMeshGeom_computeMeshVBHeap(swigCPtr, this, SWIGTYPE_p_void.getCPtr(arg0), arg1);
  }

  public boolean isActiveInstanceNeedVBFill() {
    return nel3dJNI.IMeshGeom_isActiveInstanceNeedVBFill(swigCPtr, this);
  }

  public boolean isMeshInVBHeap() {
    return nel3dJNI.IMeshGeom_isMeshInVBHeap(swigCPtr, this);
  }

  public final static class TRenderFlag {
    public final static TRenderFlag RenderOpaqueMaterial = new TRenderFlag("RenderOpaqueMaterial", nel3dJNI.IMeshGeom_RenderOpaqueMaterial_get());
    public final static TRenderFlag RenderTransparentMaterial = new TRenderFlag("RenderTransparentMaterial", nel3dJNI.IMeshGeom_RenderTransparentMaterial_get());
    public final static TRenderFlag RenderPassOpaque = new TRenderFlag("RenderPassOpaque", nel3dJNI.IMeshGeom_RenderPassOpaque_get());
    public final static TRenderFlag RenderGlobalAlpha = new TRenderFlag("RenderGlobalAlpha", nel3dJNI.IMeshGeom_RenderGlobalAlpha_get());
    public final static TRenderFlag RenderGADisableZWrite = new TRenderFlag("RenderGADisableZWrite", nel3dJNI.IMeshGeom_RenderGADisableZWrite_get());

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TRenderFlag swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TRenderFlag.class + " with value " + swigValue);
    }

    private TRenderFlag(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TRenderFlag(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TRenderFlag(String swigName, TRenderFlag swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TRenderFlag[] swigValues = { RenderOpaqueMaterial, RenderTransparentMaterial, RenderPassOpaque, RenderGlobalAlpha, RenderGADisableZWrite };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
